# Here's a bunch of hacks to work around apparent limitations in Sinatra.

# The URL path is currently not unescaped before recognition is attempted.
# This hack rectifies this for static routes only.
module Sinatra
  class Static
    def invoke(request)
      require 'cgi'
      return unless File.file?(
        Sinatra.application.options.public + CGI::unescape(request.path_info)
      )
      Result.new(block, {}, 200)
    end

    def block
      Proc.new do
        send_file(
          Sinatra.application.options.public + CGI::unescape(request.path_info),
          :disposition => nil
        )
      end
    end
  end
end
